<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html>
<head>
{include file='header.tpl' JS=$smarty.const.BAOGG_JS CSS=$smarty.const.BAOGG_CSS}      
<style type="text/css">
	tr.survey h3 {
		 background-color: #F8F8FF;
		 text-align:center;
	}
	legend {
		 background-color: #F8F8FF;
                 font-size:14px;
                 font-weight:bold;
                padding:15px 0 5px 10px;
        }

	tr.row0 {
	   background-color: #EEF6FF;
	}
	tr.row1 {
	   background-color: #EBF2FA;
	}
	tr{
	   background-color:#D2E0F2;
	   width:100%;
	   border:1px solid #D2E0F2;
	   text-align:center;
	}
	th{
	   text-align:center;
           font-weight:bold;
           font-size:12px;
           height:30px;
	}
	td select{
	   width:150px;
	   overflow:auto;
        }	
</style>
        <script type="text/javascript"> 

        var LANG={$JSLANG};
	function selectQuestionByGroup(group_id){
		Ext.Array.each( Ext.query("input[name*="+group_id+"]"),function(name,index,self){ name.checked=true; });
		Ext.Array.each( Ext.query("input[value*="+group_id+"]"),function(name,index,self){ name.checked=true; })	
	}
	function checkAll(name,is_checked){
		Ext.each(Ext.query('input[type=checkbox][name="'+name+'[]"]'),function(item,index,self){ item.checked=is_checked; })
	}
	Ext.onReady(function(){
Ext.create('Ext.container.Viewport', {
    layout: 'border',
    renderTo: Ext.getBody(),
    items: [
	
Ext.create('Ext.panel.Panel', {
    region:'center',
    contentEl: 'form',
    autoScroll:true,
    bodyBorder:true,
    dockedItems:[{
        xtype: 'toolbar',
    	dock: 'top',
	items: [
        	{ xtype: 'button', 
        		
				iconCls:'save-icon',
        		text: LANG.save,handler:function(){
			Ext.Ajax.request({
				form:'form_field',
				params:{ task:'save' },
				success:function(response,opts){
                                       var result = Ext.decode(response.responseText);
                                         top.Ext.ux.ShowResult( result);
                                         if(result.success){

					window.location.href=window.location.href;
                                        }
					//console.info('success');
					//console.info(response);
				},
				failure:function(response,opts){
					window.location.href=window.location.href;
					//console.info('fail');
					//console.info(response);
				}
			});	
		} },
		{ xtype: 'button', 
				
			iconCls:'delete-icon',
			text: LANG['delete'],handler:function(){
			Ext.Ajax.request({
				form:'form_field',
				params:{ task:'delete'},
				success:function(response,opts){
                                       var result = Ext.decode(response.responseText);
                                         top.Ext.ux.ShowResult( result);
                                         if(result.success){

					window.location.href=window.location.href;
                                        }
				},
				failure:function(response,opts){
					//console.info('fail');
					window.location.href=window.location.href;
					//console.info(response);
				}
			});	
		} }

    	]   
    }]
})
]
})		
	});
	</script>


</head>
<body>
  
       
<div id="form">


	<form id="form_field" method="post" action="{$smarty.server.PHP_SELF}">
		{$output}
	
	<fieldset>
		<legend>{$LANG.is_list}</legend>
		<table><tr><th><input type="checkbox" id='check_qa_list_id' name='check_qa_list_id' onclick='checkAll("qa_list_id",this.checked)' /></th><th>{$LANG.question_name}</th><th>{$LANG.rule_id}</th><th>{$LANG.title}</th><th>{$LANG.ordering}</th><th>{$LANG.state}</th></tr>
			{foreach $arr_list as $list}
			<tr><td><input type="checkbox" name="qa_list_id[]" value="{$list.qa_list_id}"  /></td><td>{$arr_field.{$list.qa_field_id}.qa_field_name}</td><td>{$list.rule_id}</td><td>{$list.qa_list_name}</td><td>{$list.ordering}</td><td>{$list.state}</td></tr>
			{/foreach}
		<tr><td>&nbsp;</td><td>
		<select name="add_list_qa_field_id">
		<option value="">{$LANG.please_select}</option>
		{foreach $arr_field as $field}
   			<option value="{$field.qa_field_id}">{$field.qa_field_name}</option>
		{/foreach}
		</select>
		</td>
		<td><select name="add_list_rule_id">
                        <option value="0">{$LANG.please_select}</option>

{foreach $arr_rule as $rule}
        <option value="{$rule.rule_id}">{$rule.rule_name}</option>
{/foreach}
                </select></td>
                <td><input type="text" name="add_list_qa_list_name" /></td>
		<td><input type="text" name="add_list_ordering" /></td>
		<td>
                <input type="radio" name="add_list_state" id="add_list_state_1"   value="1" checked /><label for="add_list_state_1">{$arr_state.1}</label> 
                <input type="radio" name="add_list_state" id="add_list_state_0"   value="0" /><label for="add_list_state_0">{$arr_state.0}</label> 
                </td>
                
                </tr>
                
		</table>
	</fieldset>

	<fieldset>
		<legend>{$LANG.is_chart}</legend>
		<table><tr><th><input type="checkbox"  onclick='checkAll("qa_chart_id",this.checked)' /></th><th>{$LANG.question_name}</th><th>{$LANG.axis}</th><th>{$LANG.rule_id}</th><th>{$LANG.title}</th><th>{$LANG.ordering}</th></tr>
			{foreach $arr_chart as $chart}
			<tr><td><input type="checkbox" name="qa_chart_id[]" value="{$chart.qa_chart_id}"  /></td><td>{$arr_field.{$chart.qa_field_id}.qa_field_name}</td><td>{$chart.qa_chart_type}
                        </td><td>{$chart.rule_id}</td><td>{$chart.qa_chart_name}</td><td>{$chart.ordering}</td></tr>
			{/foreach}
		<tr><td>&nbsp;</td><td>
		<select name="add_chart_qa_field_id">
		<option value="">{$LANG.please_select}</option>
		{foreach $arr_field as $field}
   			<option value="{$field.qa_field_id}">{$field.qa_field_name}</option>
		{/foreach}
		</select>
		</td><td>
		<select name="add_chart_qa_chart_type">
			<option value="0">X{$LANG.axis}</option>
			<option value="1">Y{$LANG.axis}</option>
		</select>
		</td>
		<td><select name="add_chart_rule_id">
                        <option value="0">{$LANG.please_select}</option>

{foreach $arr_rule as $rule}
        <option value="{$rule.rule_id}">{$rule.rule_name}</option>
{/foreach}
                </select></td>
                <td><input type="text" name="add_chart_qa_chart_name" /></td>
		<td><input type="text" name="add_chart_ordering" /></td></tr>
		</table>
	</fieldset>

	<fieldset>
		<legend>{$LANG.is_filter}</legend>
		<table><tr><th><input type="checkbox" onclick='checkAll("qa_filter_id",this.checked)' /></th><th>{$LANG.question_name}</th><th>{$LANG.op}</th><th>{$LANG.answer}</th><th>{$LANG.order}</th><th>{$LANG.state}</th></tr>
	 	{foreach $arr_filter as $filter}
			<tr><td><input type="checkbox" name="qa_filter_id[]" value="{$filter.qa_filter_id}" /></td><td>{$arr_field.{$filter.qa_field_id}.qa_field_name}</td><td>{$filter.operation}</td><td>{$filter.values}</td><td>{$filter.ordering}</td><td>{$filter.state}</td></tr>
		{/foreach}
		<tr><td>&nbsp;</td><td>
		<select name="add_filter_qa_field_id">
		<option value="">{$LANG.please_select}</option>
		{foreach $arr_field as $field}
   			<option value="{$field.qa_field_id}">{$field.qa_field_name}</option>
		{/foreach}
		</select>
		</td><td>
			<select name="add_filter_operation">
				<option value="">{$LANG.please_select}</option>
				{foreach $arr_operation as $code=>$operation}
   					<option value="{$code}">{$operation}</option>
				{/foreach}
			</select>
		</td><td><input type="text" name="add_filter_values" /></td>
                <td><input type="text" name="add_filter_ordering" /></td>
                <td>
                 <input type="radio" name="add_filter_state" id="add_filter_state_1"   value="1" checked /><label for="add_filter_state_1">{$arr_state.1}</label> 
                <input type="radio" name="add_filter_state" id="add_filter_state_0"   value="0" /><label for="add_filter_state_0">{$arr_state.0}</label> 

                </td>
                </tr>
		</table>
	</fieldset>
	<fieldset>
		<legend>{$LANG.is_sort}</legend>
		<table><tr><th><input type="checkbox" onclick='checkAll("qa_sort_id",this.checked)' /></th><th>{$LANG.question_name}</th><th>{$LANG.dir}</th><th>{$LANG.order}</th></tr>
			{foreach $arr_sort as $sort}
			<tr><td><input type="checkbox" name="qa_sort_id[]" value="{$sort.qa_sort_id}" /></td><td>{$arr_field.{$sort.qa_field_id}.qa_field_name}</td><td>{$sort.dir}</td><td>{$sort.ordering}</td></tr>
			{/foreach}
		<tr><td>&nbsp;</td><td>
		<select name="add_sort_qa_field_id">
		<option value="">{$LANG.please_select}</option>
		{foreach $arr_field as $field}
   			<option value="{$field.qa_field_id}">{$field.qa_field_name}</option>
		{/foreach}
		</select>
		</td><td>
		<select name="add_sort_dir">
			<option value="asc">{$LANG.asc}</option>
			<option value="desc">{$LANG.desc}</option>
		</select>
		</td><td><input type="text" name="add_sort_ordering" /></td></tr>
		</table>
	</fieldset>


	</form>
</div>



</body>
</html>
